package com.dhwl.hsh.merchant.ui.adapter;

import android.content.Context;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.dhwl.hsh.merchant.R;
import com.dhwl.hsh.lib.bean.Address;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 当前地址adapter
 *
 * @author sjx
 * @version [版本号, 2015-12-15]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class CurrentAddrAdapter extends BaseAdapter<Address> {
    private SparseBooleanArray selectionMap;


    public CurrentAddrAdapter(Context context, List<Address> list) {
        super(context, list);

        selectionMap = new SparseBooleanArray();
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;
        if (null == convertView) {
            convertView = inflate(R.layout.item_current_addr, null);
            viewHolder = new ViewHolder(convertView);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        Address address = getList().get(position);
        viewHolder.tvCurrentAddrTitle.setText(address.getPosiName());
        viewHolder.tvCurrentAddrInfo.setText(address.getPosiSubName());
        return convertView;
    }

    class ViewHolder {
        @Bind(R.id.tv_current_addr_title)
        TextView tvCurrentAddrTitle;
        @Bind(R.id.tv_current_addr_info)
        TextView tvCurrentAddrInfo;
        @Bind(R.id.img_select_addr)
        ImageView cbSelectAddr;


        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
